package com.scpii.universal.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.scpii.universal.hibernate.dao.BaseDao;
import com.scpii.universal.hibernate.entity.EnterpShopTab;
import com.scpii.universal.hibernate.intface.BaseInterface;

public class EnterpShopTabService implements BaseInterface<EnterpShopTab> {
	private static final Logger log = LoggerFactory
			.getLogger(EnterpShopTabService.class);
//	private BaseDao<EnterpShopTab> enterpShopTabDao = SpringBeanFactory.enterpShopTabDao;
	private BaseDao<EnterpShopTab> enterpShopTabDao;

	public EnterpShopTab get(Integer id) throws Exception {
		return enterpShopTabDao.get(id);
	}

	public List<EnterpShopTab> getAll() throws Exception {
		return enterpShopTabDao.getAll();
	}

	public EnterpShopTab get(String propertyName, Object value)
			throws Exception {
		return null;
	}

	public List<EnterpShopTab> getList(String propertyName, Object value)
			throws Exception {
		return null;
	}

	public Long getTotalCount() throws Exception {
		return null;
	}

	public void save(EnterpShopTab obj) throws Exception {

	}

	public void update(EnterpShopTab obj) throws Exception {

	}

	public void delete(EnterpShopTab obj) throws Exception {

	}

	public void delete(Integer id) throws Exception {

	}

	public List<EnterpShopTab> hqlGetList(String hql,
			Map<String, Object> argsMap) throws Exception {
		return enterpShopTabDao.hqlGetList(hql, argsMap);
	}

	public void hqlUpdate(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		enterpShopTabDao.hqlUpdate(namedHqlQuery, argsMap);
	}

	public Long hqlGetNums(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		return enterpShopTabDao.hqlGetNums(namedHqlQuery, argsMap);
	}

	public List<EnterpShopTab> sqlGetList(String sqls,
			Map<String, Object> argsMap) throws Exception {
		return enterpShopTabDao.sqlGetList(sqls, argsMap);
	}

	public void sqlUpdate(String sqls, Map<String, Object> argsMap)
			throws Exception {
		enterpShopTabDao.sqlUpdate(sqls, argsMap);
	}

	public Long sqlGetNum(String sqls, Map<String, Object> argsMap)
			throws Exception {
		return enterpShopTabDao.sqlGetNum(sqls, argsMap);
	}
	
	/**
	 * 根据应用ID，获得应用相关的门店信息列表
	 * @param appId
	 * @param contentId
	 * @return
	 * @throws Exception
	 * @author 甘建新
	 * 2012-7-17上午11:22:30
	 */
	public List<EnterpShopTab> getShopListByAppId(int appId, int contentId)throws Exception{
		if (appId>0) {
			List<EnterpShopTab> enterpShopList = new ArrayList<EnterpShopTab>();
			//设置传入参数
			Map<String, Object> argsMap = new HashMap<String, Object>();
			argsMap.put("appId", appId);
			if (contentId != 0) {
				argsMap.put("contentId", contentId);
				enterpShopList = this.hqlGetList("GET_ENTERPSHOP_BY_CONTENTID", argsMap);
			} else {
				//调用查询方法
				enterpShopList = this.hqlGetList("GET_ENTERPSHOP_BY_APPID", argsMap);
			}
			return enterpShopList;
		}
		return null;
	}
	
	public List<EnterpShopTab> getShopByPageNo(final int pageNo, final int pageSize,
			final String sql, final Map<String,Object> map) throws Exception {
		return (List<EnterpShopTab>) enterpShopTabDao.findBySql(pageNo, pageSize, sql, map);
	}

	//Setter
	public void setEnterpShopTabDao(BaseDao<EnterpShopTab> enterpShopTabDao) {
		this.enterpShopTabDao = enterpShopTabDao;
	}
}